//
// Created by 23602 on 25-8-28.
//

#include "canvas.hpp"
#include "line.hpp"
#include "triangle.hpp"


void Canvas::drawLine(const sf::Vector2f& p0, const sf::Vector2f& p1, const sf::Color& color)
{
    auto line = createLine(p0, p1);
    putPixel(line, color);
}

void Canvas::drawTriangle(const sf::Vector2f& p0, const sf::Vector2f& p1, const sf::Vector2f& p2, const sf::Color& color)
{
    auto triangle = createTriangle(p0, p1, p2);
    putPixel(triangle, color);
}

void Canvas::drawFilledTriangle(const sf::Vector2f& p0, const sf::Vector2f& p1, const sf::Vector2f& p2, const sf::Color& color)
{
    auto triangle = createFilledTriangle(p0, p1, p2);
    putPixel(triangle, color);
}

Vector2f Canvas::transformCoord(const sf::Vector2f& coord) const
{
    float x = SCREEN_WIDTH / 2 + coord.x;
    float y = SCREEN_HEIGHT / 2 - coord.y - 1;
    return {x, y};
}
